package com.chens.common.controller;

import com.chens.common.security.JwtTokenUtils;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BaseController {

    @Autowired
    private JwtTokenUtils jwtTokenUtils;

    protected String getCurrentUsername(HttpServletRequest request) {
        String token = jwtTokenUtils.getJwtFromRequest(request);
        return jwtTokenUtils.getUsernameFromJWT(token);
    }
}
